//
//  ViewController.swift
//  AAChartKit-Swift
//
//  Created by An An  on 17/4/18.
//  Copyright © 2017年 An An . All rights reserved.
//*************** ...... SOURCE CODE ...... ***************
//***...................................................***
//*** https://github.com/AAChartModel/AAChartKit        ***
//*** https://github.com/AAChartModel/AAChartKit-Swift  ***
//***...................................................***
//*************** ...... SOURCE CODE ...... ***************
/*
 
 *********************************************************************************
 *
 *  🌕 🌖 🌗 🌘  ❀❀❀   WARM TIPS!!!   ❀❀❀ 🌑 🌒 🌓 🌔
 *
 * Please contact me on GitHub,if there are any problems encountered in use.
 * GitHub Issues : https://github.com/AAChartModel/AAChartKit-Swift/issues
 * -------------------------------------------------------------------------------
 * And if you want to contribute for this project, please contact me as well
 * GitHub        : https://github.com/AAChartModel
 * StackOverflow : https://stackoverflow.com/users/7842508/codeforu
 * JianShu       : https://www.jianshu.com/u/f1e6753d4254
 * SegmentFault  : https://segmentfault.com/u/huanghunbieguan
 *
 *********************************************************************************
 
 */


import UIKit

class SpecialChartVC: UIViewController {
    open var chartType: AAChartType!
    open var aaChartModel: AAChartModel!
    open var aaChartView: AAChartView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = .white
        title = chartType!.rawValue
        
        setUpAAChartView()
    }
    
   private func setUpAAChartView() {
 
        aaChartView = AAChartView()
        let chartWidth = view.frame.size.width
        let chartHeight = view.frame.size.height
        aaChartView!.frame = CGRect(x: 0,
                                    y: 60,
                                    width: chartWidth,
                                    height: chartHeight)
        aaChartView!.contentHeight = view.frame.size.height - 80
        view.addSubview(aaChartView!)
        aaChartView!.scrollEnabled = false
        
        aaChartModel = configureTheAAChartModel(chartType!)
        aaChartView!.aa_drawChartWithChartModel(aaChartModel!)
    }
    
   private func configureTheAAChartModel(_ chartTypeStr:AAChartType) -> AAChartModel {
        switch chartTypeStr {
        case .column: return configureColumnChart()
        case .pie: return configurePieChart()
        case .bubble: return configureBubbleChart()
        case .scatter: return configureScatterChart()
        case .arearange: return configureArearangeChart()
        case .areasplinerange: return configureAreasplinerangeChart()
        case .columnrange: return configureColumnrangeChart()
        case .line: return configureStepLineChart()
        case .area: return configureStepAreaChart()
        case .boxplot: return configureBoxplotChart()
        case .waterfall: return configureWaterfallChart()
        case .pyramid: return configurePyramidChart()
        case .funnel: return configureFunnelChart()
        case .errorbar: return configureErrobarChart()
        default: return configureColumnChart()
        }
    }
    
   private func configureColumnChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.column)
            .polar(true)
            .dataLabelsEnabled(false)
            .categories(["January", "February", "March", "April", "May", "June",
                         "July", "August", "September", "October", "November", "December"])
            .marginLeft(50)
            .marginRight(30)
            .series([
                AASeriesElement()
                    .name("2018")
                    .data([7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6])
                    .colorByPoint(true)
                
                ]
    )
    }
    
   private func configurePieChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.pie)
            .backgroundColor(AAColor.white)
            .title("LANGUAGE MARKET SHARES JANUARY,2020 TO MAY")
            .subtitle("virtual data")
            .dataLabelsEnabled(true)//是否直接显示扇形图数据
            .yAxisTitle("℃")
            .series([
                AASeriesElement()
                    .name("Language market shares")
                    .innerSize("20%")//内部圆环半径大小占比(内部圆环半径/扇形图半径),
                    .allowPointSelect(false)
                    .data([
                        ["Java"  ,67],
                        ["Swift",999],
                        ["Python",83],
                        ["OC"    ,11],
                        ["Go"    ,30],
                        ])
                ,
                ]
    )
    }
    
   private func configureBubbleChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.bubble)
            .title("AACHARTKIT BUBBLES")
            .subtitle("JUST FOR FUN")
            .yAxisTitle("℃")
            .colorsTheme(["#0c9674","#7dffc0","#d11b5f","#facd32","#ffffa0","#EA007B"])
            .series([
                AASeriesElement()
                    .name("BubbleOne")
                    .data([
                        [97, 36, 79],
                        [94, 74, 60],
                        [68, 76, 58],
                        [64, 87, 56],
                        [68, 27, 73],
                        [74, 99, 42],
                        [7,  93, 99],
                        [51, 69, 40],
                        [38, 23, 33],
                        [57, 86, 31],
                        [33, 24, 22]
                        ])
                ,
                AASeriesElement()
                    .name("BubbleTwo")
                    .data([
                        [25, 60, 87],
                        [2,  75, 59],
                        [11, 54, 8 ],
                        [86, 55, 93],
                        [5,  33, 88],
                        [90, 63, 44],
                        [91, 43, 17],
                        [97, 56, 56],
                        [15, 67, 48],
                        [54, 25, 81],
                        [55, 66, 11]
                        ])
                ,
                AASeriesElement()
                    .name("BubbleThree")
                    .data([
                        [47, 47, 21],
                        [20, 12, 66],
                        [6,  76, 91],
                        [38, 30, 60],
                        [57, 98, 64],
                        [61, 47, 80],
                        [83, 60, 13],
                        [67, 78, 75],
                        [64, 12, 55],
                        [30, 77, 82],
                        [88, 66, 13]
                        ])
                ,
                ]
    )
        
    }
    
    private func configureScatterChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.scatter)
            .title("Height and weight distribution by sex")
            .titleFontColor(AAColor.white)
            .axesTextColor(AAColor.white)
            .yAxisTitle("kg")
            .markerSymbol(.circle)
            .markerSymbolStyle(.innerBlank)
            .markerRadius(9)
            .backgroundColor("#22324c")
            .dataLabelsEnabled(false)
            .series([
                AASeriesElement()
                    .name("Female")
                    .color(AAColor.rgbaColor(223,83,83,1))
                    .data([
                        [161.2, 51.6], [167.5, 59.0], [159.5, 49.2], [157.0, 63.0], [155.8, 53.6],
                        [170.0, 59.0], [159.1, 47.6], [166.0, 69.8], [176.2, 66.8], [160.2, 75.2],
                        [172.5, 55.2], [170.9, 54.2], [172.9, 62.5], [153.4, 42.0], [160.0, 50.0],
                        [147.2, 49.8], [168.2, 49.2], [175.0, 73.2], [157.0, 47.8], [167.6, 68.8],
                        [159.5, 50.6], [175.0, 82.5], [166.8, 57.2], [176.5, 87.8], [170.2, 72.8],
                        [174.0, 54.5], [173.0, 59.8], [179.9, 67.3], [170.5, 67.8], [160.0, 47.0],
                        [154.4, 46.2], [162.0, 55.0], [176.5, 83.0], [160.0, 54.4], [152.0, 45.8],
                        [162.1, 53.6], [170.0, 73.2], [160.2, 52.1], [161.3, 67.9], [166.4, 56.6],
                        [168.9, 62.3], [163.8, 58.5], [167.6, 54.5], [160.0, 50.2], [161.3, 60.3],
                        [167.6, 58.3], [165.1, 56.2], [160.0, 50.2], [170.0, 72.9], [157.5, 59.8],
                        [167.6, 61.0], [160.7, 69.1], [163.2, 55.9], [152.4, 46.5], [157.5, 54.3],
                        [168.3, 54.8], [180.3, 60.7], [165.5, 60.0], [165.0, 62.0], [164.5, 60.3],
                        [156.0, 52.7], [160.0, 74.3], [163.0, 62.0], [165.7, 73.1], [161.0, 80.0],
                        [162.0, 54.7], [166.0, 53.2], [174.0, 75.7], [172.7, 61.1], [167.6, 55.7],
                        [151.1, 48.7], [164.5, 52.3], [163.5, 50.0], [152.0, 59.3], [169.0, 62.5],
                        [164.0, 55.7], [161.2, 54.8], [155.0, 45.9], [170.0, 70.6], [176.2, 67.2],
                        [170.0, 69.4], [162.5, 58.2], [170.3, 64.8], [164.1, 71.6], [169.5, 52.8],
                        [163.2, 59.8], [154.5, 49.0], [159.8, 50.0], [173.2, 69.2], [170.0, 55.9],
                        [161.4, 63.4], [169.0, 58.2], [166.2, 58.6], [159.4, 45.7], [162.5, 52.2],
                        [159.0, 48.6], [162.8, 57.8], [159.0, 55.6], [179.8, 66.8], [162.9, 59.4],
                        [161.0, 53.6], [151.1, 73.2], [168.2, 53.4], [168.9, 69.0], [173.2, 58.4],
                        [171.8, 56.2], [178.0, 70.6], [164.3, 59.8], [163.0, 72.0], [168.5, 65.2],
                        [166.8, 56.6], [172.7, 88.8], [163.5, 51.8], [169.4, 63.4], [167.8, 59.0],
                        [159.5, 47.6], [167.6, 63.0], [161.2, 55.2], [160.0, 45.0], [163.2, 54.0],
                        [162.2, 50.2], [161.3, 60.2], [149.5, 44.8], [157.5, 58.8], [163.2, 56.4],
                        [172.7, 62.0], [155.0, 49.2], [156.5, 67.2], [164.0, 53.8], [160.9, 54.4],
                        [162.8, 58.0], [167.0, 59.8], [160.0, 54.8], [160.0, 43.2], [168.9, 60.5],
                        [158.2, 46.4], [156.0, 64.4], [160.0, 48.8], [167.1, 62.2], [158.0, 55.5],
                        [167.6, 57.8], [156.0, 54.6], [162.1, 59.2], [173.4, 52.7], [159.8, 53.2],
                        [170.5, 64.5], [159.2, 51.8], [157.5, 56.0], [161.3, 63.6], [162.6, 63.2],
                        [160.0, 59.5], [168.9, 56.8], [165.1, 64.1], [162.6, 50.0], [165.1, 72.3],
                        [166.4, 55.0], [160.0, 55.9], [152.4, 60.4], [170.2, 69.1], [162.6, 84.5],
                        [170.2, 55.9], [158.8, 55.5], [172.7, 69.5], [167.6, 76.4], [162.6, 61.4],
                        [167.6, 65.9], [156.2, 58.6], [175.2, 66.8], [172.1, 56.6], [162.6, 58.6],
                        [160.0, 55.9], [165.1, 59.1], [182.9, 81.8], [166.4, 70.7], [165.1, 56.8],
                        [177.8, 60.0], [165.1, 58.2], [175.3, 72.7], [154.9, 54.1], [158.8, 49.1],
                        [172.7, 75.9], [168.9, 55.0], [161.3, 57.3], [167.6, 55.0], [165.1, 65.5],
                        [175.3, 65.5], [157.5, 48.6], [163.8, 58.6], [167.6, 63.6], [165.1, 55.2],
                        [165.1, 62.7], [168.9, 56.6], [162.6, 53.9], [164.5, 63.2], [176.5, 73.6],
                        [168.9, 62.0], [175.3, 63.6], [159.4, 53.2], [160.0, 53.4], [170.2, 55.0],
                        [162.6, 70.5], [167.6, 54.5], [162.6, 54.5], [160.7, 55.9], [160.0, 59.0],
                        [157.5, 63.6], [162.6, 54.5], [152.4, 47.3], [170.2, 67.7], [165.1, 80.9],
                        [172.7, 70.5], [165.1, 60.9], [170.2, 63.6], [170.2, 54.5], [170.2, 59.1],
                        [161.3, 70.5], [167.6, 52.7], [167.6, 62.7], [165.1, 86.3], [162.6, 66.4],
                        [152.4, 67.3], [168.9, 63.0], [170.2, 73.6], [175.2, 62.3], [175.2, 57.7],
                        [160.0, 55.4], [165.1, 77.7], [174.0, 55.5], [170.2, 77.3], [160.0, 80.5],
                        [167.6, 64.5], [167.6, 72.3], [167.6, 61.4], [154.9, 58.2], [162.6, 81.8],
                        [175.3, 63.6], [171.4, 53.4], [157.5, 54.5], [165.1, 53.6], [160.0, 60.0],
                        [174.0, 73.6], [162.6, 61.4], [174.0, 55.5], [162.6, 63.6], [161.3, 60.9],
                        [156.2, 60.0], [149.9, 46.8], [169.5, 57.3], [160.0, 64.1], [175.3, 63.6],
                        [169.5, 67.3], [160.0, 75.5], [172.7, 68.2], [162.6, 61.4], [157.5, 76.8],
                        [176.5, 71.8], [164.4, 55.5], [160.7, 48.6], [174.0, 66.4], [163.8, 67.3]
                        ])
                ,
                AASeriesElement()
                    .name("Male")
                    .color(AAColor.rgbaColor(119,152,191,1))
                    .data([
                        [174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],
                        [181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],
                        [180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],
                        [184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],
                        [176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],
                        [178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],
                        [183.5, 74.8], [175.5, 70.0], [188.0, 72.4], [189.2, 84.1], [172.8, 69.1],
                        [170.0, 59.5], [182.0, 67.2], [170.0, 61.3], [177.8, 68.6], [184.2, 80.1],
                        [186.7, 87.8], [171.4, 84.7], [172.7, 73.4], [175.3, 72.1], [180.3, 82.6],
                        [182.9, 88.7], [188.0, 84.1], [177.2, 94.1], [172.1, 74.9], [167.0, 59.1],
                        [169.5, 75.6], [174.0, 86.2], [172.7, 75.3], [182.2, 87.1], [164.1, 55.2],
                        [163.0, 57.0], [171.5, 61.4], [184.2, 76.8], [174.0, 86.8], [174.0, 72.2],
                        [177.0, 71.6], [186.0, 84.8], [167.0, 68.2], [171.8, 66.1], [182.0, 72.0],
                        [167.0, 64.6], [177.8, 74.8], [164.5, 70.0], [192.0, 99.9], [175.5, 63.2],
                        [171.2, 79.1], [181.6, 78.9], [167.4, 67.7], [181.1, 66.0], [177.0, 68.2],
                        [174.5, 63.9], [177.5, 72.0], [170.5, 56.8], [182.4, 74.5], [197.1, 90.9],
                        [180.1, 93.0], [175.5, 80.9], [180.6, 72.7], [184.4, 68.0], [175.5, 70.9],
                        [180.6, 72.5], [177.0, 72.5], [177.1, 83.4], [181.6, 75.5], [176.5, 73.0],
                        [175.0, 70.2], [174.0, 73.4], [165.1, 70.5], [177.0, 68.9], [192.0, 99.7],
                        [176.5, 68.4], [169.4, 65.9], [182.1, 75.7], [179.8, 84.5], [175.3, 87.7],
                        [184.9, 86.4], [177.3, 73.2], [167.4, 53.9], [178.1, 72.0], [168.9, 55.5],
                        [157.2, 58.4], [180.3, 83.2], [170.2, 72.7], [177.8, 64.1], [172.7, 72.3],
                        [165.1, 65.0], [186.7, 86.4], [165.1, 65.0], [174.0, 88.6], [175.3, 84.1],
                        [185.4, 66.8], [177.8, 75.5], [180.3, 93.2], [180.3, 82.7], [177.8, 58.0],
                        [177.8, 79.5], [177.8, 78.6], [177.8, 71.8], [177.8, 88.8], [163.8, 72.2],
                        [188.0, 83.6], [198.1, 85.5], [175.3, 90.9], [166.4, 85.9], [190.5, 89.1],
                        [166.4, 75.0], [177.8, 77.7], [179.7, 86.4], [172.7, 90.9], [190.5, 73.6],
                        [185.4, 76.4], [168.9, 69.1], [167.6, 84.5], [175.3, 64.5], [170.2, 69.1],
                        [190.5,108.6], [177.8, 86.4], [190.5, 80.9], [177.8, 87.7], [184.2, 94.5],
                        [176.5, 80.2], [177.8, 72.0], [180.3, 71.4], [171.4, 72.7], [172.7, 84.1],
                        [172.7, 76.8], [177.8, 63.6], [177.8, 80.9], [182.9, 80.9], [170.2, 85.5],
                        [167.6, 68.6], [175.3, 67.7], [165.1, 66.4], [185.4, 77.7], [181.6, 70.5],
                        [172.7, 95.9], [190.5, 84.1], [179.1, 87.3], [175.3, 71.8], [170.2, 65.9],
                        [193.0, 95.9], [171.4, 91.4], [177.8, 81.8], [177.8, 96.8], [167.6, 69.1],
                        [167.6, 82.7], [180.3, 75.5], [182.9, 79.5], [176.5, 73.6], [186.7, 91.8],
                        [188.0, 84.1], [188.0, 85.9], [177.8, 81.8], [174.0, 82.5], [177.8, 80.5],
                        [171.4, 70.0], [185.4, 81.8], [185.4, 84.1], [188.0, 90.5], [188.0, 91.4],
                        [182.9, 89.1], [176.5, 85.0], [175.3, 69.1], [175.3, 73.6], [188.0, 80.5],
                        [188.0, 82.7], [175.3, 86.4], [170.5, 67.7], [179.1, 92.7], [177.8, 93.6],
                        [175.3, 70.9], [182.9, 75.0], [170.8, 93.2], [188.0, 93.2], [180.3, 77.7],
                        [177.8, 61.4], [185.4, 94.1], [168.9, 75.0], [185.4, 83.6], [180.3, 85.5],
                        [174.0, 73.9], [167.6, 66.8], [182.9, 87.3], [160.0, 72.3], [180.3, 88.6],
                        [167.6, 75.5], [186.7, 66.8], [175.3, 91.1], [175.3, 67.3], [175.9, 77.7],
                        [175.3, 81.8], [179.1, 75.5], [181.6, 84.5], [177.8, 76.6], [182.9, 85.0],
                        [177.8, 81.8], [184.2, 77.3], [179.1, 71.8], [176.5, 87.9], [188.0, 94.3],
                        [174.0, 70.9], [167.6, 64.5], [170.2, 77.3], [167.6, 72.3], [188.0, 87.3],
                        [174.0, 80.0], [176.5, 82.3], [180.3, 73.6], [167.6, 74.1], [188.0, 85.9],
                        [180.3, 73.2], [167.6, 76.3], [183.0, 65.9], [183.0, 90.9], [179.1, 89.1],
                        [170.2, 62.3], [177.8, 82.7], [179.1, 79.1], [190.5, 98.2], [177.8, 84.1],
                        [180.3, 83.2], [180.3, 83.2]
                        ])
                
                ]
        )
    }
    
    private func configureArearangeChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.arearange)
            .title("Twilight Hall day temperature fluctuation map")
            .subtitle("real-time monitoring data")
            .yAxisTitle("℃")
            .dataLabelsEnabled(false)
            .series([
                AASeriesElement()
                    .name("2020")
                    .data([
                        /* 2014-01-01 */
                        [13885380, 1.1,  4.7],
                        [13886244, 1.8,  6.4],
                        [13887108, 1.7,  6.9],
                        [13887972, 2.6,  7.4],
                        [13888836, 3.3,  9.3],
                        [13889700, 3.0,  7.9],
                        [13890564, 3.9,  6.0],
                        [13891428, 3.9,  5.5],
                        [13892292, -0.6, 4.5],
                        [13893156, -0.5, 5.3],
                        [13894020, -0.3, 2.4],
                        [13894884, -6.5,-0.4],
                        [13895748, -7.3,-3.4],
                        [13896612, -7.3,-2.3],
                        [13897476, -7.9,-4.2],
                        [13898340, -4.7, 0.9],
                        [13899204, -1.2, 0.4],
                        [13900068, -2.3,-0.1],
                        [13900932, -2.0, 0.3],
                        [13901796, -5.1,-2.0],
                        [13902660, -4.4,-0.5],
                        [13903524, -6.4,-2.7],
                        [13904388, -3.2,-0.5],
                        [13905252, -5.5,-0.8],
                        [13906116, -4.4, 2.4],
                        [13906980, -4.0, 1.1],
                        [13907844, -3.4, 0.8],
                        [13908708, -1.7, 2.6],
                        [13909572, -3.1, 3.9],
                        [13910436, -8,  -1.9],
                        [13911300, -7,  -2.8],
                        /* 2014-02-01 */
                        [13912164, -2.7, 2.6],
                        [13913028, -1.3, 8.2],
                        [13913892, 1.5,  7.7],
                        [13914756, -0.5, 5.3],
                        [13915620, -0.2, 5.2],
                        [13916484, 0.7,  4.8],
                        [13917348, 0.9,  5.7],
                        [13918212, 1.7,  3.9],
                        [13919076, 2.2,  8.8],
                        [13919940, 3.0,  6.6],
                        [13920804, 1.4,  5.4],
                        [13921668, 0.6,  5.1],
                        [13922532, 0.1,  7.8],
                        [13923396, 3.4,  7.3],
                        [13924260, 2.0,  5.9],
                        [13925124, 1.1,  4.7],
                        [13925988, 1.1,  4.4],
                        [13926852, -2.8, 2.6],
                        [13927716, -5.0, 0.1],
                        [13928580, -5.7, 0.2],
                        [13929444, -0.7, 3.9],
                        [13930308, 1.5,  7.8],
                        [13931172, 5.5,  8.8],
                        [13932036, 5.3, 11.7],
                        [13932900, 1.7, 11.1],
                        [13933764, 3.4,  9.3],
                        [13934628, 3.4,  7.3],
                        [13935492, 4.5,  8.0],
                        /* 2014-03-01 */
                        [13936356, 2.1,  8.9],
                        [13937220, 0.6,  6.1],
                        [13938084, 1.2,  9.4],
                        [13938948, 2.6,  7.3],
                        [13939812, 3.9,  9.5],
                        [13940676, 5.3,  9.9],
                        [13941540, 2.7,  7.1],
                        [13942404, 4.0,  8.6],
                        [13943268, 6.1, 10.7],
                        [13944132, 4.2,  7.6],
                        [13944996, 2.5,  9.0],
                        [13945860, 0.2,  7.0],
                        [13946724, -1.2, 6.9],
                        [13947588, 0.4,  6.7],
                        [13948452, 0.2,  5.1],
                        [13949316, -0.1, 6.0],
                        [13950180, 1.0,  5.6],
                        [13951044, -1.1, 6.3],
                        [13951908, -1.9, 0.3],
                        [13952772, 0.3,  4.5],
                        [13953636, 2.4,  6.7],
                        [13954500, 3.2,  9.2],
                        [13955364, 1.7,  3.6],
                        [13956228, -0.3, 7.9],
                        [13957092, -2.4, 8.6],
                        [13957956, -1.7,10.3],
                        [13958820, 4.1, 10.0],
                        [13959684, 4.4, 14.0],
                        [13960548, 3.3, 11.0],
                        [13961412, 3.0, 12.5],
                        [13962240, 1.4, 10.4],
                        /* 2014-04-01 */
                        [13963104, -1.2, 8.8],
                        [13963968, 2.2,  7.6],
                        [13964832, -1.0,10.1],
                        [13965696, -1.8, 9.5],
                        [13966560, 0.2,  7.7],
                        [13967424, 3.7,  6.4],
                        [13968288, 5.8, 11.4],
                        [13969152, 5.4,  8.7],
                        [13970016, 4.5, 12.2],
                        [13970880, 3.9,  8.4],
                        [13971744, 4.5,  8.0],
                        [13972608, 6.6,  8.4],
                        [13973472, 3.7,  7.3],
                        [13974336, 3.6,  6.7],
                        [13975200, 3.5,  8.3],
                        [13976064, 1.5, 10.2],
                        [13976928, 4.9,  9.4],
                        [13977792, 3.5, 12.0],
                        [13978656, 1.5, 13.1],
                        [13979520, 1.7, 15.6],
                        [13980384, 1.4, 16.0],
                        [13981248, 3.0, 18.4],
                        [13982112, 5.6, 18.8],
                        [13982976, 5.7, 17.2],
                        [13983840, 4.5, 16.4],
                        [13984704, 3.1, 17.6],
                        [13985568, 4.7, 18.9],
                        [13986432, 4.9, 16.6],
                        [13987296, 6.8, 15.6],
                        [13988160, 2.8,  9.2],
                        /* 2014-05-01 */
                        [13989024, -2.7,10.5],
                        [13989888, -1.9,10.9],
                        [13990752, 4.5,  8.5],
                        [13991616, -0.6,10.4],
                        [13992480, 4.0,  9.7],
                        [13993344, 5.5,  9.5],
                        [13994208, 6.5, 13.2],
                        [13995072, 3.2, 14.5],
                        [13995936, 2.1, 13.5],
                        [13996800, 6.5, 15.6],
                        [13997664, 5.7, 16.2],
                        [13998528, 6.3, 15.3],
                        [13999392, 5.3, 15.3],
                        [14000256, 6.0, 14.1],
                        [14001120, 1.9,  7.7],
                        [14001984, 7.2,  9.8],
                        [14002848, 8.9, 15.2],
                        [14003712, 9.1, 20.5],
                        [14004576, 8.4, 17.9],
                        [14005440, 6.8, 21.5],
                        [14006304, 7.6, 14.1],
                        [14007168, 11.1,16.5],
                        [14008032, 9.3, 14.3],
                        [14008896, 10.4,19.3],
                        [14009760, 5.7, 19.4],
                        [14010624, 7.9, 17.9],
                        [14011488, 5.0, 22.5],
                        [14012352, 7.6, 22.0],
                        [14013216, 5.7, 21.9],
                        [14014080, 4.6, 20.0],
                        [14014944, 7.0, 22.0],
                        /* 2014-06-01 */
                        [14015808, 5.1, 20.6],
                        [14016672, 6.6, 24.6],
                        [14017536, 9.7, 22.2],
                        [14018400, 9.6, 21.6],
                        [14019264, 13.0,20.0],
                        [14020128, 12.9,18.2],
                        [14020992, 8.5, 23.2],
                        [14021856, 9.2, 21.4],
                        [14022720, 10.5,22.0],
                        [14023584, 7.3, 23.4],
                        [14024448, 12.1,18.2],
                        [14025312, 11.1,13.3],
                        [14026176, 10.0,20.7],
                        [14027040, 5.8, 23.4],
                        [14027904, 7.4, 20.1],
                        [14028768, 10.3,21.9],
                        [14029632, 7.8, 16.8],
                        [14030496, 11.6,19.7],
                        [14031360, 9.8, 16.0],
                        [14032224, 10.7,14.4],
                        [14033088, 9.0, 15.5],
                        [14033952, 5.1, 13.3],
                        [14034816, 10.0,19.3],
                        [14035680, 5.2, 22.1],
                        [14036544, 6.3, 21.3],
                        [14037408, 5.5, 21.1],
                        [14038272, 8.4, 19.7],
                        [14039136, 7.1, 23.3],
                        [14040000, 6.1, 20.8],
                        [14040864, 8.4, 22.6],
                        /* 2014-07-01 */
                        [14041728, 7.6, 23.3],
                        [14042592, 8.1, 21.5],
                        [14043456, 11.2,18.1],
                        [14044320, 6.4, 14.9],
                        [14045184, 12.7,23.1],
                        [14046048, 15.3,21.7],
                        [14046912, 15.1,19.4],
                        [14047776, 10.8,22.8],
                        [14048640, 15.8,29.7],
                        [14049504, 15.8,29.0],
                        [14050368, 15.2,30.5],
                        [14051232, 14.9,28.1],
                        [14052096, 13.1,27.4],
                        [14052960, 15.5,23.5],
                        [14053824, 14.7,20.1],
                        [14054688, 14.4,16.8],
                        [14055552, 12.6,18.5],
                        [14056416, 13.9,24.4],
                        [14057280, 11.3,26.9],
                        [14058144, 13.3,27.4],
                        [14059008, 13.3,29.7],
                        [14059872, 14.0,28.8],
                        [14060736, 14.1,29.8],
                        [14061600, 15.4,31.1],
                        [14062464, 17.0,26.5],
                        [14063328, 16.6,27.1],
                        [14064192, 13.3,25.6],
                        [14065056, 16.8,21.9],
                        [14065920, 16.0,22.8],
                        [14066784, 14.4,19.0],
                        [14067648, 12.8,18.1],
                        /* 2014-08-01 */
                        [14068512, 12.6,18.0],
                        [14069376, 11.4,19.7],
                        [14070240, 13.9,18.9],
                        [14071104, 12.5,19.9],
                        [14071968, 12.3,23.4],
                        [14072832, 12.8,23.3],
                        [14073696, 11.0,20.4],
                        [14074560, 14.7,22.4],
                        [14075424, 11.1,23.6],
                        [14076288, 13.5,20.7],
                        [14077152, 13.7,23.1],
                        [14078016, 12.8,19.6],
                        [14078880, 12.1,18.7],
                        [14079744, 8.8, 22.4],
                        [14080608, 8.2, 20.1],
                        [14081472, 10.9,16.3],
                        [14082336, 10.7,16.1],
                        [14083200, 11.0,18.9],
                        [14084064, 12.1,14.7],
                        [14084928, 11.2,14.4],
                        [14085792, 9.9, 16.6],
                        [14086656, 6.9, 15.7],
                        [14087520, 8.9, 15.3],
                        [14088384, 8.2, 17.6],
                        [14089248, 8.4, 19.5],
                        [14090112, 6.6, 19.9],
                        [14090976, 6.4, 19.7],
                        [14091840, 0,      0],
                        [14092704, 0,      0],
                        [14093568, 0,      0],
                        [14094432, 0,      0],
                        /* 2014-09-01 */
                        [14095296, 0,      0],
                        [14096160, 0,      0],
                        [14097024, 0,      0],
                        [14097888, 0,      0],
                        [14098752, 0,      0],
                        [14099616, 13.4,13.4],
                        [14100480, 13.2,17.1],
                        [14101344, 11.9,18.9],
                        [14102208, 9.0, 15.9],
                        [14103072, 5.9, 17.5],
                        [14103936, 6.8, 16.2],
                        [14104800, 10.3,19.9],
                        [14105664, 8.7, 17.9],
                        [14106528, 7.9, 19.1],
                        [14107392, 6.0, 20.1],
                        [14108256, 4.7, 19.9],
                        [14109120, 4.0, 18.8],
                        [14109984, 4.5, 17.9],
                        [14110848, 3.1, 16.1],
                        [14111712, 8.5, 12.2],
                        [14112576, 7.6, 13.8],
                        [14113440, 1.3, 12.6],
                        [14114304, 2.0, 10.9],
                        [14115168, 5.0, 10.8],
                        [14116032, 6.4, 10.1],
                        [14116896, 8.2, 13.3],
                        [14117760, 8.9, 11.8],
                        [14118624, 9.9, 15.9],
                        [14119488, 5.2, 12.5],
                        [14120352, 4.6, 11.7],
                        /* 2014-10-01 */
                        [14121216, 8.8, 12.1],
                        [14122080, 3.9, 12.3],
                        [14122944, 2.7, 18.1],
                        [14123808, 10.2,18.2],
                        [14124672, 9.6, 17.9],
                        [14125536, 9.3, 17.5],
                        [14126400, 8.1, 12.7],
                        [14127264, 6.7, 11.2],
                        [14128128, 4.0, 10.0],
                        [14128992, 6.3, 10.2],
                        [14129856, 6.6, 10.7],
                        [14130720, 6.6, 10.3],
                        [14131584, 5.9, 10.4],
                        [14132448, 1.2, 10.6],
                        [14133312, -0.1, 9.2],
                        [14134176, -1.0, 9.4],
                        [14135040, -1.7, 8.3],
                        [14135904, -0.6, 7.5],
                        [14136768, 6.9, 10.1],
                        [14137632, 7.7, 10.5],
                        [14138496, 3.8,  9.7],
                        [14139360, 6.2,  8.6],
                        [14140224, 6.5,  9.2],
                        [14141088, 7.9, 10.7],
                        [14141952, 6.1, 10.9],
                        [14142816, 10.3,13.1],
                        [14143716, 7.1, 13.3],
                        [14144580, 0.0, 10.1],
                        [14145444, 0.0,  5.7],
                        [14146308, 3.9,  4.6],
                        [14147172, 4.0,  4.8],
                        /* 2014-11-01 */
                        [14148036, 4.8, 11.2],
                        [14148900, 7.0,  8.5],
                        [14149764, 3.0,  9.8],
                        [14150628, 2.8,  5.9],
                        [14151492, 0.8,  4.8],
                        [14152356, -0.2, 2.9],
                        [14153220, -0.6, 5.5],
                        [14154084, 6.6, 10.3],
                        [14154948, 5.4,  7.3],
                        [14155812, 3.0,  8.4],
                        [14156676, 0.4,  3.2],
                        [14157540, -0.1, 6.8],
                        [14158404, 4.8,  8.8],
                        [14159268, 4.6,  8.5],
                        [14160132, 4.3,  7.7],
                        [14160996, 3.3,  7.5],
                        [14161860, -0.4, 3.2],
                        [14162724, 1.9,  4.7],
                        [14163588, -0.2, 3.7],
                        [14164452, -1.3, 2.1],
                        [14165316, -1.8, 0.9],
                        [14166180, -2.7, 1.3],
                        [14167044, 0.3,  2.5],
                        [14167908, 3.4,  6.5],
                        [14168772, 0.8,  6.1],
                        [14169636, -1.0, 1.3],
                        [14170500, 0.4,  3.1],
                        [14171364, -1.2, 1.9],
                        [14172228, -1.1, 2.8],
                        [14173092, -0.7, 1.8],
                        /* 2014-12-01 */
                        [14173956, 0.5,  2.5],
                        [14174820, 1.4,  3.2],
                        [14175684, 4.5, 10.2],
                        [14176548, 0.4, 10.0],
                        [14177412, 2.5,  3.7],
                        [14178276, 1.1,  5.0],
                        [14179140, 2.0,  4.4],
                        [14180004, 1.4,  2.2],
                        [14180868, 0.7,  4.6],
                        [14181732, 1.9,  3.9],
                        [14182596, -0.2, 3.7],
                        [14183460, -0.1, 1.7],
                        [14184324, -1.0, 3.8],
                        [14185188, 0.5,  5.4],
                        [14186052, -1.7, 5.6],
                        [14186916, 0.3,  2.8],
                        [14187780, -3.0, 0.4],
                        [14188644, -1.1, 1.5],
                        [14189508, 0.8,  3.4],
                        [14190372, 0.9,  4.4],
                        [14191236, 0.3,  3.9],
                        [14192100, 0.6,  5.3],
                        [14192964, 1.5,  4.4],
                        [14193828, 0,      0],
                        [14194692, 0,      0],
                        [14195556, 10.6,   4],
                        [14196420, 10.8,   5],
                        [14197284, 8.4,    4],
                        [14198148, 5.2,  2.4],
                        [14199012, 1.3,  2.5],
                        [14199876, 1.6,  4.2]
                        ])
                ]
        )
    }
    
    private func configureAreasplinerangeChart() -> AAChartModel {
        let gradientColorDic = AAGradientColor.linearGradient(
            direction: .toBottomRight,
            startColor: "#8A2BE2",
            endColor: "#1E90FF"//颜色字符串设置支持十六进制类型和 rgba 类型
        )
        
        return AAChartModel()
            .chartType(.areasplinerange)
            .title("Area spline range chart")
            .subtitle("virtual data")
            .yAxisTitle("℃")
            .series([
                AASeriesElement()
                    .name("2020")
                    .color(gradientColorDic)
                    .data([
                        /* 2014-06-01 */
                        [14015808, 5.1, 20.6],
                        [14016672, 6.6, 24.6],
                        [14017536, 9.7, 22.2],
                        [14018400, 9.6, 21.6],
                        [14019264, 13.0,20.0],
                        [14020128, 12.9,18.2],
                        [14020992, 8.5, 23.2],
                        [14021856, 9.2, 21.4],
                        [14022720, 10.5,22.0],
                        [14023584, 7.3, 23.4],
                        [14024448, 12.1,18.2],
                        [14025312, 11.1,13.3],
                        [14026176, 10.0,20.7],
                        [14027040, 5.8, 23.4],
                        [14027904, 7.4, 20.1],
                        [14028768, 10.3,21.9],
                        [14029632, 7.8, 16.8],
                        [14030496, 11.6,19.7],
                        [14031360, 9.8, 16.0],
                        [14032224, 10.7,14.4],
                        [14033088, 9.0, 15.5],
                        [14033952, 5.1, 13.3],
                        [14034816, 10.0,19.3],
                        [14035680, 5.2, 22.1],
                        [14036544, 6.3, 21.3],
                        [14037408, 5.5, 21.1],
                        [14038272, 8.4, 19.7],
                        [14039136, 7.1, 23.3],
                        [14040000, 6.1, 20.8],
                        [14040864, 8.4, 22.6],
                        ])
                ])
    }
    
    private func configureColumnrangeChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.columnrange)
            .title("TEMPERATURE VARIATION BY MONTH")
            .subtitle("observed in Gotham city")
            .yAxisTitle("℃")
            .categories([
                "January", "February", "March", "April", "May", "June",
                "July", "August", "September", "October", "November", "December"
            ])
            .dataLabelsEnabled(true)
            .inverted(true)//x 轴是否垂直翻转
            .series([
                AASeriesElement()
                    .name("temperature")
                    .data([
                        [-9.7,  9.4],
                        [-8.7,  6.5],
                        [-3.5,  9.4],
                        [-1.4, 19.9],
                        [0.0,  22.6],
                        [2.9,  29.5],
                        [9.2,  30.7],
                        [7.3,  26.5],
                        [4.4,  18.0],
                        [-3.1, 11.4],
                        [-5.2, 10.4],
                        [-13.5, 9.8]
                        ])
                ]
        )
    }
    
    private func configureStepLineChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.line)//图形类型
            .animationType(.bounce)//图形渲染动画类型为"bounce"
            .title("STEP LINE CHART")//图形标题
            .subtitle("2020/08/08")//图形副标题
            .dataLabelsEnabled(false)//是否显示数字
            .markerSymbolStyle(.borderBlank)//折线连接点样式
            .markerRadius(7)//折线连接点半径长度,为0时相当于没有折线连接点
            .series([
                AASeriesElement()
                    .name("Berlin")
                    .data([450, 432, 401, 454, 590, 530, 510])
                    .step("right")//设置折线样式为直方折线,折线连接点位置靠右👉
                    ,
                AASeriesElement()
                    .name("New York")
                    .data([220, 282, 201, 234, 290, 430, 410])
                    .step("center")//设置折线样式为直方折线,折线连接点位置居中
                    ,
                AASeriesElement()
                    .name("Tokyo")
                    .data([120, 132, 101, 134, 90, 230, 210])
                    .step("left")//设置折线样式为直方折线,折线连接点位置靠左👈
                    ,
                ])
    }
    
    private func configureStepAreaChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.area)//图形类型
            .animationType(.bounce)//图形渲染动画类型为"bounce"
            .title("STEP AREA CHART")//图形标题
            .subtitle("2049/08/08")//图形副标题
            .dataLabelsEnabled(false)//是否显示数字
            .markerSymbolStyle(.innerBlank)//折线连接点样式
            .markerRadius(0)//折线连接点半径长度,为0时相当于没有折线连接点
            .series([
                AASeriesElement()
                    .name("Berlin")
                    .data([450, 432, 401, 454, 590, 530, 510])
                    .step(true)//设置折线样式为直方折线,折线连接点位置靠左👈
                    ,
                AASeriesElement()
                    .name("New York")
                    .data([220, 282, 201, 234, 290, 430, 410])
                    .step(true)//设置折线样式为直方折线,折线连接点位置靠左👈
                    ,
                AASeriesElement()
                    .name("Tokyo")
                    .data([120, 132, 101, 134, 90, 230, 210])
                    .step(true)//设置折线样式为直方折线,折线连接点位置靠左👈
                    ,
                ])
    }
    
    private func configureBoxplotChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.boxplot)
            .title("BOXPLOT CHART")
            .subtitle("virtual data")
            .yAxisTitle("℃")
            .yAxisVisible(true)
            .series([
                AASeriesElement()
                    .name("Observed Data")
                    .color("#ef476f")
                    .fillColor("#04d69f")
                    .data([
                        [760, 801, 848, 895, 965],
                        [733, 853, 939, 980, 1080],
                        [714, 762, 817, 870, 918],
                        [724, 802, 806, 871, 950],
                        [834, 836, 864, 882, 910]
                        ])
                    ,
                ])
    }
    
    private func configureWaterfallChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.waterfall)
            .title("WATERFALL CHART")
            .subtitle("virtual data")
            .yAxisVisible(true)
            .series([
                AASeriesElement()
                    .color("#ef476f")
                    .borderWidth(0)
                    .data([
                        [
                            "name": "启动资金",
                            "y": 120000
                        ], [
                            "name": "产品收入",
                            "y": 569000
                        ], [
                            "name": "服务收入",
                            "y": 231000
                        ], [
                            "name": "正平衡",
                            "isIntermediateSum": true,
                            "color": "#ffd066"
                        ], [
                            "name": "固定成本",
                            "y": -342000
                        ], [
                            "name": "可变成本",
                            "y": -233000
                        ], [
                            "name": "余额",
                            "isSum": true,
                            "color": "#04d69f"
                        ]])
                    ]
        )
    }
    
    private func configurePyramidChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.pyramid)
            .title("THE HEAT OF PROGRAM LANGUAGE")
            .subtitle("virtual data")
            .yAxisTitle("℃")
            .series([
                AASeriesElement()
                    .name("2020")
                    .data([
                        ["swift",      11850],
                        ["Objective-C",12379],
                        ["JavaScript", 14286],
                        ["Go",         15552],
                        ["Python",     18654],
                        ])
                    ,
                ])
    }
    
    private func configureFunnelChart() -> AAChartModel {
        return AAChartModel()
            .chartType(.funnel)
            .title("THE HEAT OF PROGRAM LANGUAGE")
            .subtitle("virtual data")
            .yAxisTitle("℉")
            .series([
                AASeriesElement()
                    .name("2020")
                    .data([
                        ["swift",      11256],
                        ["Objective-C",12365],
                        ["JavaScript", 13569],
                        ["Go",         15221],
                        ["Python",     16298],
                        ])
                    ,
                ])
    }
    
    private func configureErrobarChart() -> AAChartModel {
        return AAChartModel()
            .yAxisTitle("")
            .categories([
                "一月", "二月", "三月", "四月", "五月", "六月",
                "七月", "八月", "九月", "十月", "十一月", "十二月"
            ])
            .series([
                AASeriesElement()
                    .name("降水")
                    .type(.column)
                    .data([49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4])
                ,
                AASeriesElement()
                    .name("降雨误差")
                    .type(.errorbar)
                    .lineWidth(2.5)
                    .color(AAColor.red)
                    .data([[48, 51], [68, 73], [92, 110], [128, 136], [140, 150], [171, 179], [135, 143], [142, 149], [204, 220], [189, 199], [95, 110], [52, 56]])
                    .tooltip(AATooltip()
                            .pointFormat("(误差范围: {point.low}-{point.high} mm)<br/>"))
            ])
    }
}

